//
//  bankItem.m
//  jiaKaoZhuShou
//
//  Created by 金艺社 on 2018/5/21.
//  Copyright © 2018年 金艺社. All rights reserved.
//

#import "bankItem.h"

@implementation bankItem

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.headImage];
        [self addSubview:self.title];
        [self addSubview:self.subtitle];
    }
    [self addConstraints];
    return self;
}
- (void)addConstraints {
    [self.headImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self);
        make.width.height.equalTo(@30);
    }];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headImage);
        make.left.equalTo(self.headImage.mas_right).offset(3);
        make.right.equalTo(self);
        make.height.equalTo(@30);
    }];
    [self.subtitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.top.equalTo(self.headImage.mas_bottom).offset(2);
    }];
}
#pragma mark --- getter
- (UIImageView *)headImage {
    if (!_headImage) {
        _headImage = [UIImageView new];
    }
    return _headImage;
}
- (UILabel *)title {
    if (!_title) {
        _title = [UILabel new];
        _title.font = [UIFont customFontOfSize:15];
        _title.textColor = [UIColor blackColor];
    }
    return _title;
}
- (UILabel *)subtitle {
    if (!_subtitle) {
        _subtitle = [UILabel new];
        _subtitle.font = [UIFont customFontOfSize:11];
        _subtitle.textColor = [UIColor custom_color:@"#999999"];
    }
    return _subtitle;
}
@end
